fix(spaces): prevent duplicate "Leave without saving?" modal on solution view cancel#260958
Open
fix(spaces): prevent duplicate "Leave without saving?" modal on solution view cancel#260958
Conversation
… change Agent-Logs-Url: https://github.com/elastic/kibana/sessions/bb2f6605-71ea-4bd7-aad6-c15b59cf95ff Co-authored-by: legrego <3493255+legrego@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix duplicate modal in edit Space on Solution view change
fix(spaces): prevent duplicate "Leave without saving?" modal on solution view cancel
Apr 2, 2026
legrego
approved these changes
Apr 2, 2026
Member
legrego
left a comment
There was a problem hiding this comment.
LGTM - tested locally, does what it says on the tin
Contributor
|
Pinging @elastic/kibana-security (Team:Security) |
kc13greiner
approved these changes
Apr 2, 2026
Contributor
kc13greiner
left a comment
There was a problem hiding this comment.
LGTM! Message only pops up once 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changing the solution view in the edit Space page and then clicking Cancel caused the "Leave without saving?" modal to appear twice — once on Cancel, and again after clicking Leave.
Root cause
onSolutionViewChangecallsonChangeFeatures, which sets bothisDirty=trueandshowUserImpactWarning=true. When the user clicks Cancel,onClickCancelcallssetShowUserImpactWarning(false)— a real state transition — triggering a React re-render whilehistory.push('/')is already in flight. During that re-render,useUnsavedChangesPromptre-runs its effect (itspropsobject is a new reference every render), which tears down the old history block and registers a new one. The user's "Leave" click unblocks only the old block;navigateToUrl()then hits the new block and shows the modal again.This only manifests for solution view changes because it's the only path that sets
showUserImpactWarning=true, makingsetShowUserImpactWarning(false)inonClickCancela meaningful state change that causes a re-render.Fix
Add
setIsDirty(false)toonClickCancel. Since React batches state updates within event handlers,history.push('/')still fires synchronously against the existing block (modal appears as expected). But on the subsequent re-render,useUnsavedChangesPromptseeshasUnsavedChanges=falseand exits early — no new block is registered, sonavigateToUrl()navigates cleanly.const onClickCancel = useCallback(() => { setShowAlteringActiveSpaceDialog(false); setShowUserImpactWarning(false); + setIsDirty(false); backToSpacesList(); }, [backToSpacesList]);Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
ci-stats.kibana.dev/home/REDACTED/.nvm/versions/node/v22.22.0/bin/node /home/REDACTED/.nvm/versions/node/v22.22.0/bin/node scripts/yarn_install_scripts.js run ldd 0.8.2 nibrowser-gtk/sys/lib/libjxl.so.0.8 plugins/private/canvas/public/components/with_debounce_arg/index.ts e_modules/npm/bin/node-gyp-bin/ldd plugins/private//lib64/ld-linux-x86-64.so.2 plugins/private/--verify plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/lib/libwpe-1.0.so.1.9.3 ldd b/li�� plugins/private/install plugins/private/canvas/public/components/palette_picker/stops_palette_picker/stop_color_picker.t/home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/lib/libsoup-3.0.so.0.7.4 n/node-gyp-bin/ldd ]*/[^/]*/share/mldd plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/lib/libjxl.so.0.8 dd .2(dns block)/home/REDACTED/.nvm/versions/node/v22.22.0/bin/node /home/REDACTED/.nvm/versions/node/v22.22.0/bin/node scripts/kbn bootstrap ases/public/comp/home/REDACTED/work/kibana/kibana/x-pack/platform/plugins/private/monitoring/server/lib/details/get_series.ts ases�� ases/public/components/observables/observable_actions_popover_button.test.tsx ases/public/components/observables/fields_config.ts plugins/shared/ml/public/applica/home/REDACTED/work/kibana/kibana/x-pack/platform/plugins/shared/s^(prefix|globalconfig) *= plugins/shared/mcurl plugins/shared/m-V plugins/shared/ml/public/applicauseUnsavedChangesPrompt plugins/shared/ml/public/applica/home/REDACTED/work/kibana/kibana/x-pack/platform/plugins/private/monitoring/server/lib/elasticsearch/indices/get_indices.ts plug�� plugins/shared/ml/public/applica/home/REDACTED/work/kibana/kibana/x-pack/platform/plugins/private/head plugins/shared/cases/public/comp/home/REDACTED/work/kibana/kibana/x-pack/platform/plugins/private/-n plugins/shared/cases/public/comp/home/REDACTED/work/kibana/kibana/x-pack/platform/plugins/private/1 plugins/shared/cawk plugins/shared/cBEGIN { if (ARGV[1] == "" || ARGV[2] == "") exit(1) split(ARGV[1], a, /\./); split(ARGV[2], b, /\./); for (i=1; i<=3; i++) { if (a[i] && a[i] !~ /^[0-9]+$/) exit(2); if (b[i] && b[i] !~ /^[0-9]+$/) { exit(0); } if (a[i] < plugins/shared/cases/public/comp--log-level(dns block)/home/REDACTED/.nvm/versions/node/v22.22.0/bin/node node scripts/jest x-pack/platform/plugins/shared/spaces/public/management/edit_space/edit_space_general_tab.test.tsx --no-coverage s/li�� x-pack/platform/plugins/shared/s^(prefix|globalconfig) *= x-pack/platform/plugins/shared/streams_app/publif() { test "$1" = get && echo "****** v22.22.0/lib/node_modules/npm/bin/node-gyp-bin/ldd x-pack/platform/git x-pack/platform/remote s/npm/bin/node-gget-url ldd nibr�� x-pack/platform/plugins/private/1 r ndor/bin/ldd x-pack/platform/git x-pack/platform/config s/npm/bin/node-guser.email /lib64/ld-linux-x86-64.so.2(dns block)clients3.google.com/home/REDACTED/work/kibana/kibana/node_modules/@moonrepo/core-linux-x64-gnu/moon /home/REDACTED/work/kibana/kibana/node_modules/@moonrepo/core-linux-x64-gnu/moon run :build-webpack ldd b/li�� plugins/private/NVM_DIR=/home/REDACTED/.nvm plugins/private/-v dd plugins/private/ldd plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/li�� dd /lib/ld-linux.so.2 b/li�� plugins/private/canvas/public/co--fail plugins/private/canvas/public/co--compressed m/versions/node/v22.22.0/lib/node_modules/npm/bin/node-gyp-bin/ldd plugins/private/ldd plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/lib/libjxl.so.0.8 x-pack/platform/plugins/shared/s-o ldd(dns block)detectportal.firefox.com/home/REDACTED/work/kibana/kibana/node_modules/@moonrepo/core-linux-x64-gnu/moon /home/REDACTED/work/kibana/kibana/node_modules/@moonrepo/core-linux-x64-gnu/moon run :build-webpack ldd b/li�� plugins/private/NVM_DIR=/home/REDACTED/.nvm plugins/private/-v dd plugins/private/ldd plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/li�� dd /lib/ld-linux.so.2 b/li�� plugins/private/canvas/public/co--fail plugins/private/canvas/public/co--compressed m/versions/node/v22.22.0/lib/node_modules/npm/bin/node-gyp-bin/ldd plugins/private/ldd plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/lib/libjxl.so.0.8 x-pack/platform/plugins/shared/s-o ldd(dns block)google.com/home/REDACTED/work/kibana/kibana/node_modules/@moonrepo/core-linux-x64-gnu/moon /home/REDACTED/work/kibana/kibana/node_modules/@moonrepo/core-linux-x64-gnu/moon run :build-webpack ldd b/li�� plugins/private/NVM_DIR=/home/REDACTED/.nvm plugins/private/-v dd plugins/private/ldd plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/li�� dd /lib/ld-linux.so.2 b/li�� plugins/private/canvas/public/co--fail plugins/private/canvas/public/co--compressed m/versions/node/v22.22.0/lib/node_modules/npm/bin/node-gyp-bin/ldd plugins/private/ldd plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/lib/libjxl.so.0.8 x-pack/platform/plugins/shared/s-o ldd(dns block)googlechromelabs.github.io/home/REDACTED/.nvm/versions/node/v22.22.0/bin/node /home/REDACTED/.nvm/versions/node/v22.22.0/bin/node install.js plugins/shared/alerting/server/application/backfill/methods/schedule/index.ts ldd b/li�� plugins/shared/a--show-toplevel system# !d; /lib/node_modules/npm/bin/node-gyp-bin/ldd plugins/shared/aldd plugins/shared/a/home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/li��(dns block)iojs.org/usr/bin/curl curl -q --fail --compressed -L -s REDACTED -o - treams_app/publipush treams_app/publi-v treams_app/publiorigin trea�� treams_app/publi/home/REDACTED/work/kibana/kibana/x-pack/platform/plugins/shared/entity_manager/setr canvas/public/components/arg_form/arg_simple_form.tsx canvas/public/components/color_dot/index.ts canvas/public/cobash canvas/public/co--norc canvas/public/co--noprofile canvas/public/components/with_debounce_arg/index.ts(dns block)If you need me to access, download, or install something from one of these locations, you can either: